/**
 * @projectName study-note
 * @package Interpreter
 * @className Interpreter.Test
 */
package Interpreter;

import java.lang.reflect.Method;

/**
 * Test
 * @description 测试类
 * @author answer_wx
 * @date 2022/7/6 15:33
 * @version 1.0
 */
public class Test {
    public static void main(String[] args) throws Exception {
        Context context = new Context();
        System.out.println("上海滩");
        context.setText("O 2 E 0.5 G 0.5 E 0.5 A 3 E 0.5 G 0.5 D 3 ");
        AbstractExpression expression = null;
        ExpressionFactory factory = new ExpressionFactory();
        while (!context.getText().isEmpty()) {
            String str = context.getText().substring(0, 1);
            if ("O".equals(str)) {
                expression = (AbstractExpression) ExpressionFactory.class.getMethod("scale").invoke(factory);
            } else {
                expression = (AbstractExpression)
                        ExpressionFactory.class.getMethod("note").invoke(factory);
            }
            expression.interpreter(context);
        }
    }
}